<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<div class="paginator clearfix">
	<div class="col-md-4 paginator_num">
		共<em>${page.rows }</em>条记录&nbsp;当前<em>${page.currentPage }</em>/<em>${page.totalPage }</em>页
		<select class="form-control select" name="pageSize" style="width:100px;" onchange="pageSizeChange2(this)">
			<option <c:if test="${page.pageSize==2 }">selected</c:if> value="2">2</option>
			<option <c:if test="${page.pageSize==10 }">selected</c:if> value="10">10</option>
			<option <c:if test="${page.pageSize==20 }">selected</c:if> value="20">20</option>
			<option <c:if test="${page.pageSize==50 }">selected</c:if> value="50">50</option>
		</select>
	</div>
	<nav aria-label="Page navigation" class="col-md-4 paginator_pagination">
		<ul class="pagination">
			<li><a href="<%=basePath %>${page.pageUrl }?currentPage=1">首页</a></li>
			<li><a href="<%=basePath %>${page.pageUrl }?currentPage=${page.currentPage-1 }" aria-label="Previous" class="icon-double-left"></a></li>
			<c:forEach begin="${page.currentPage-4>0?page.currentPage-4:1 }" end="${page.currentPage+4 }" step="1" var="i">
				<c:if test="${i>0 && i<=page.totalPage }">
					<li ${i==page.currentPage?"class='active'":"" }>
						<a href="<%=basePath %>${page.pageUrl }?currentPage=${i }">${i}</a>
					</li>
				</c:if>
			</c:forEach>
			<li><a href="<%=basePath %>${page.pageUrl }?currentPage=${page.currentPage+1 }" aria-label="Next" class="icon-double-right"></a></li>
			<li><a href="<%=basePath %>${page.pageUrl }?currentPage=${page.totalPage }">尾页</a></li>
		</ul>
	</nav>
	<div class="col-md-4 paginator_jump">
		<form action="<%=basePath %>${page.pageUrl }" class="clearfix" id="pageInputForm" method="post">
			<input type="number" min="1" max="${page.totalPage }" class="form-control" id="pageInputNumber" name="currentPage" value="${page.currentPage }"
						onkeyup="limitPageNumber2(this,${page.totalPage })"
						onchange="limitPageNumber2(this,${page.totalPage })">
			<input type="text" style="display:none;">
			<input type="button" class="btn btn1" value="跳转" onclick="goToPage();">
		</form>
	</div>
</div>
<script  type="text/javascript">
function limitPageNumber2(obj,max){
	obj.value=obj.value.replace(/\D/g,'');
	if(obj.value.trim()=="") return;
	if(obj.value<1) obj.value=1;
	if(obj.value>max) obj.value=max;
}

function pageSizeChange2(obj){
	var url=location.href;
	url=setUrlParam(url,'pageSize',obj.value)
	location.href=url;
}

function goToPage(){
	var page=document.getElementById("pageInputNumber").value;
	if(page=='') return;
	document.getElementById("pageInputForm").submit();
}
</script>